<!--精品推荐-->
<template>
    <div class="recommend">
      <h2>精品推荐</h2>
      <div id="banner_recommend">
        <swiper class="swiper-container banner clearfix" id="banner" ref="mySwiper" :options="swiperOption">
          <swiper-slide class="swiper-slide" v-for="(item,index) in recommend" :key="index">
            <a @click="goXq(index)"  v-for="(list,iIndex) in item" :key="iIndex">
              <img @click="goXq(index)"  :src="list.imgUrl" alt="">
              <span>{{list.title}}</span>
              <em>{{list.author}}</em>
            </a>
          </swiper-slide>
        </swiper>
      </div>
    </div>
</template>

<script>
  import { swiper, swiperSlide } from 'vue-awesome-swiper'
  export default {
    name: 'recommend',
    props: ['recommend'],
    data () {
      return {
        swiperOption: {
          notNextTick: true,
          autoplay: 3000,
          effect: 'slide',
          grabCursor: true,
          setWrapperSize: true,
          mousewheelControl: true,
          observeParents: true,
          loop: true,
          autoplayDisableOnInteraction: false
        }
      }
    },
    components: {
      swiper,
      swiperSlide
    },
    computed: {
      swiper () {
        return this.$refs.mySwiper.swiper
      }
    },
    methods: {
      goXq (bookid) {
        this.$router.push( { name: 'bookinfo', params: { bookid: bookid }})
      }
    }    
  }
</script>


<style scoped>
  .recommend{
    background: #fff;
    margin-top: 10px;
    padding-top: 16px;
    width: 320px;
    overflow: hidden;
  }
  .recommend h2{
    margin: 0px 16px 10px;
    border-left: 6px solid #f60;
    text-indent: 8px;
    font-size: 18px;
    height: 16px;
    line-height: 16px;
    font-weight: normal;
  }
  .recommend .swiper-container{
    margin: 0;
    height: auto;
  }
  .recommend .swiper-container .swiper-slide{
    float:left;
    width: 320px;
  }
  .recommend .swiper-container .swiper-slide a{
    float:left;
    display: block;
    width: 25%;
    padding:8px;
  }
  .recommend .swiper-container .swiper-slide a img{
    width: 64px;
    border-right: 5px solid #DDD;
    border-bottom: 3px solid #CCC;
    box-shadow: 1px 2px 3px rgba(0,0,0,.3)

  }
  .recommend .swiper-container .swiper-slide a em{
    display: block;
    overflow:hidden;
    white-space:nowrap;
    text-overflow:ellipsis;
    -o-text-overflow:ellipsis;
    text-align: center;
    color:#999;
    font-size: 12px;
  }
  .recommend .swiper-container .swiper-slide a span{
    display: block;
    overflow:hidden;
    white-space:nowrap;
    text-overflow:ellipsis;
    -o-text-overflow:ellipsis;
    font-size: 14px;
    color:#666;
    text-align: center;
  }
</style>
